/**
 * @description Description
 *
 * @author Candy <candy.yan@motionglobal.com>
 * @date  Creation Date 2018/7/30
 */

import ApiPath from "@/mock-data/ApiPath"
const Mock = require("mockjs");

import { templateWaitToConfirm } from './supplierPOJsonData/waitToConfirm';
import { templateConfirmed } from './supplierPOJsonData/confirmed';
import { templateWaitToShip } from './supplierPOJsonData/waitToShip';
import { templateShipped } from './supplierPOJsonData/shipped';

Mock.mock(ApiPath.supplierPO.waitToConfirm, 'get', templateWaitToConfirm);
Mock.mock(ApiPath.supplierPO.waitToConfirmSubmit, 'post', function (options) {
  return {
    title: 'wait to confirm submit',
    status_code : 1,
    msg: 'Post data successful'
  }
});
Mock.mock(ApiPath.supplierPO.waitToConfirmExcelExport, 'post', function (options) {
  return {
    title: 'wait to confirm export file',
    status_code : 1,
    msg: 'Export excel successful',
    data: JSON.parse(options.body).export_data
  }
});
Mock.mock(ApiPath.supplierPO.waitToConfirmExcelImport, 'post', function (options) {
  return {
    title: 'wait to confirm import file',
    status_code : 1,
    msg: 'Import excel successful',
    data: [
      {
        Exp_QTY:1,
        UPC:"762753932570",
        brand:"Smith",
        category:"Designer Sunglasses",
        colour_code:"1ED/XB",
        from_PO:"Marco_20180611_2",
        order_QTY:1,
        product_code:"368338",
        product_name:"Smith PIVLOCK ASANA/N",
        size:"99",
        status:"wait to update",
        status_text:"stock confirmed",
        tag:"3987817"
      },
      {
        Exp_QTY:0,
        UPC:"66468967604",
        brand:"Tom Ford",
        category:"Designer Glasses",
        colour_code:"20",
        from_PO:"Marco_20180611_2",
        order_QTY:1,
        product_code:"267507",
        product_name:"Tom Ford FT5357",
        size:"52",
        status:"wait to update",
        status_text:"back ordered",
        tag:"3987816"
      }
    ]
  }
});

Mock.mock(ApiPath.supplierPO.confirmed, 'get', templateConfirmed);
var  confirmed_UPC = '762753932570';
Mock.mock(ApiPath.supplierPO.confirmedSearch + '?UPC=' + confirmed_UPC, 'get', function (options) {
  return {
    title: 'search confirmed items',
    status_code: 1,
    msg: 'Search items successful',
    data: [
      {
        Exp_QTY:1,
        UPC:"762753932570",
        brand:"Smith",
        category:"Designer Sunglasses",
        colour_code:"1ED/XB",
        from_PO:"Marco_20180611_2",
        order_QTY:1,
        product_code:"368338",
        product_name:"Smith PIVLOCK ASANA/N",
        size:"99",
        status:"wait to update",
        status_text:"stock confirmed",
        tag:"3987817"
      }
    ]
  }
});

Mock.mock(ApiPath.supplierPO.waitToShipSearch, 'get', templateConfirmed);
var  waitToShip_UPC = '762753932570';
Mock.mock(ApiPath.supplierPO.waitToShipSearch + '?UPC=' + waitToShip_UPC, 'get', function (options) {
  return {
    title: 'search wait to ship items',
    status_code: 1,
    msg: 'Search items successful',
    data: [
      {
        Exp_QTY:1,
        UPC:"762753932570",
        brand:"Smith",
        category:"Designer Sunglasses",
        colour_code:"1ED/XB",
        from_PO:"Marco_20180611_2",
        order_QTY:1,
        product_code:"368338",
        product_name:"Smith PIVLOCK ASANA/N",
        size:"99",
        status:"wait to update",
        status_text:"stock confirmed",
        tag:"3987817"
      }
    ]
  }
});

Mock.mock(ApiPath.supplierPO.waitToShip, 'get', templateWaitToShip);
Mock.mock(ApiPath.supplierPO.waitToShipSubmit, 'post', function (options) {
  return {
    title: 'wait to confirm submit',
    status_code : 1,
    msg: 'Post data successful'
  }
});
Mock.mock(ApiPath.supplierPO.waitToShipExcelExport, 'post', function (options) {
  return {
    title: 'wait to ship export file',
    status_code : 1,
    msg: 'Export excel successful',
    data: JSON.parse(options.body).export_data
  }
});
Mock.mock(ApiPath.supplierPO.waitToShipExcelImport, 'post', function (options) {
  return {
    title: 'wait to ship import file',
    status_code : 1,
    msg: 'Import excel successful',
    data: {
      shipment_items: [
        {
          Exp_QTY:1,
          UPC:"762753932570",
          brand:"Smith",
          category:"Designer Sunglasses",
          colour_code:"1ED/XB",
          from_PO:"Marco_20180611_2",
          order_QTY:1,
          product_code:"368338",
          product_name:"Smith PIVLOCK ASANA/N",
          size:"99",
          tag:"3987817",
          unit_price: '$200',
          discount: '10%',
          special_discount: '5%',
          net_price: '$171',
          total_price: '$171'
        },
        {
          Exp_QTY:1,
          UPC:"66468967604",
          brand:"Tom Ford",
          category:"Designer Glasses",
          colour_code:"20",
          from_PO:"Marco_20180611_2",
          order_QTY:1,
          product_code:"267507",
          product_name:"Tom Ford FT5357",
          size:"52",
          tag:"3987816",
          unit_price: '$349',
          discount: '20%',
          special_discount: '2%',
          net_price: '$273.616',
          total_price: '$273.616'
        }
      ],
      invoice_detail: {
        fullfillment: 'Hong Kong',
        supplierCourier: 'DHL',
        dispatchDate: '2018-07-15',
        ETA: '2018-07-20',
        tracking: '12345678',
        shippingFee: '$0',
        invoice: '34aJMNHK',
        invoiceDate: '2018-07-22',
        invoiceAttachment: '',
        notes: 'something'
      }
    }
  }
});

Mock.mock(ApiPath.supplierPO.createShipUploadInvoice, 'post', function (options) {
  console.log('importData', options.body)
  return {
    title: 'create ship import file',
    status_code : 1,
    msg: 'Upload Image successful',
    data: [
      {
        name: 'Marco invoice.pdf',
        default_img: 'pdf'
      },
      {
        name: 'Marco2 invoice.pdf',
        default_img: 'pdf'
      },
      {
        name: 'Marco3 invoice.pdf',
        default_img: 'pdf'
      },
      {
        name: 'Marco4 invoice.xlsx',
        default_img: 'excel'
      },
      {
        name: 'Marco35invoice.xlsx',
        default_img: 'excel'
      }
    ]
  }
});
Mock.mock(ApiPath.supplierPO.createShipSubmit, 'post', function (options) {
  return {
    title: 'create ship',
    status_code : 1,
    msg: 'Create ship successful',
    data: {
    }
  }
});

Mock.mock(ApiPath.supplierPO.shipped, 'get', templateShipped);

Mock.mock(ApiPath.supplierPO.shipmentDetail, 'get', function (options) {
  return {
    title: 'wait to ship import file',
    status_code: 1,
    msg: 'Import excel successful',
    data: {
      shiped_items: [
        {
          Exp_QTY:1,
          UPC:"762753932570",
          brand:"Smith",
          category:"Designer Sunglasses",
          colour_code:"1ED/XB",
          from_PO:"Marco_20180611_2",
          order_QTY:1,
          product_code:"368338",
          product_name:"Smith PIVLOCK ASANA/N",
          size:"99",
          tag:"3987817",
          unit_price: '$200',
          discount: '10%',
          special_discount: '5%',
          net_price: '$171',
          total_price: '$171'
        },
        {
          Exp_QTY:1,
          UPC:"66468967604",
          brand:"Tom Ford",
          category:"Designer Glasses",
          colour_code:"20",
          from_PO:"Marco_20180611_2",
          order_QTY:1,
          product_code:"267507",
          product_name:"Tom Ford FT5357",
          size:"52",
          tag:"3987816",
          unit_price: '$349',
          discount: '20%',
          special_discount: '2%',
          net_price: '$273.616',
          total_price: '$273.616'
        }
      ],
      invoice_detail: {
        fullfillment: 'Hong Kong',
        supplierCourier: 'DHL',
        dispatchDate: '2018-07-15',
        ETA: '2018-07-20',
        tracking: '12345678',
        shippingFee: '$0',
        invoice: '34aJMNHK',
        invoiceDate: '2018-07-22',
        invoiceAttachment: [
          {
            name: 'Marco invoice.pdf',
            default_img: 'pdf'
          },
          {
            name: 'Marco2 invoice.pdf',
            default_img: 'pdf'
          },
          {
            name: 'Marco3 invoice.pdf',
            default_img: 'pdf'
          },
          {
            name: 'Marco4 invoice.xlsx',
            default_img: 'excel'
          },
          {
            name: 'Marco35invoice.xlsx',
            default_img: 'excel'
          }
        ],
        notes: 'something'
      }
    }
  }
});
var  shipment = 'ActiveEyewear(Ship)_218614_5';
Mock.mock(ApiPath.supplierPO.shipmentSearch + '?shipment=' + shipment, 'get', function (options) {
  return {
    title: 'search shipment items',
    status_code: 1,
    msg: 'Search items successful',
    data: [
      {
        'shipment': 'ActiveEyewear(Ship)_218614_5',
        'fulfillment': 'HK',
        'create_date': '218-6-14 19:9:23',
        'tran_qty': 1,
        'rev_qty': 1,
        'dispatch_date': '2018-8-3',
        'ETA': '2018-8-23',
        'received_date': '2018-8-24',
        'tracking_no': '1234556677',
        'status': 'Shipment Sent'
      }
    ]
  }
});
